﻿<UserControl x:Class="EpiDashboard.ExportControl"
             x:Name="ucExportControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
             mc:Ignorable="d" 
             xmlns:EpiDashboard="clr-namespace:EpiDashboard"
             Background="#00FFFFFF">    
    <Grid>        
            <Grid x:Name="ConfigGrid" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="5,5,5,5" >
            <Rectangle Fill="#22000000" RadiusX="10" RadiusY="10" Margin="0,4,0,0" />
                <Rectangle Fill="#775C90B2" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0,0,0,5" />
                <Rectangle Fill="#DDFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="5,5,5,10" />
                <StackPanel Orientation="Vertical" Margin="15" HorizontalAlignment="Center" VerticalAlignment="Top" >

                <TextBlock Text="Export Data" FontWeight="Bold" Margin="0, 0, 0, 10" />

                <TextBlock Text="This gadget will export the current set of records to one of the available formats below. To proceed, first select an output format. Then click the ... button next to Connection Information to specify a database. Finally, select a table or spreadsheet from within the database." TextWrapping="WrapWithOverflow" MaxWidth="430" HorizontalAlignment="Left" Margin="0, 0, 0, 10" />

                <TextBlock Text="Output format" ></TextBlock>
                <ComboBox x:Name="cmbDataFormats" Margin="0,0,0,8"></ComboBox>

                <TextBlock Text="Connection information" ></TextBlock>
                <Grid Name="grdConnectionInformation" Margin="0,0,0,8">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="5"></ColumnDefinition>
                        <ColumnDefinition Width="22"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBox x:Name="txtConnectionInformation" Grid.Row="0" Grid.Column="0" IsEnabled="False" HorizontalAlignment="Left" Width="394" MaxWidth="394" />
                    <Button x:Name="btnConnectionBrowse" Content="..." Grid.Row="0" Grid.Column="2" Click="btnConnectionBrowse_Click" />
                </Grid>

                <TextBlock x:Name="tblockDestinationTable"  Text="Destination table" ></TextBlock>
                <ComboBox x:Name="cmbDestinationTable" IsEditable="True"  Margin="0,0,0,8" SelectionChanged="cmbDestinationTable_SelectionChanged"></ComboBox>

                <TextBlock VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="0,0,0,0" Text="Fields to export:" TextAlignment="Center" />
                <ListBox HorizontalAlignment="Left" Margin="0,0,0,8" Name="lbxExportFields" SelectedIndex="0" SelectionMode="Extended" Width="422" MinHeight="44" MaxHeight="225" />
                <TextBlock x:Name="tblockFieldCount" Text="0 fields selected" FontSize="10" Margin="0,0,0,12"></TextBlock>
                <CheckBox x:Name="checkboxTabOrder" Content="Sort variables by tab order" Visibility="Visible" IsEnabled="true" Margin="0,0,0,8"  />
                <CheckBox x:Name="checkboxUsePrompts" Content="Use field prompts" Visibility="Collapsed" IsEnabled="true" Margin="0,0,0,8"  />

                <StackPanel x:Name="pnlStatus" Margin="0,0,0,10">
                    <StackPanel x:Name="pnlError" Height="Auto" Width="Auto" Background="Tomato" Visibility="Visible" Margin="0,0,0,2">
                        <StackPanel x:Name="pnlErrorTop" Height="2" Width="Auto" Background="Red"/>
                        <TextBlock x:Name="txtError" Text="Error: Exception occurred." TextWrapping="WrapWithOverflow" MaxWidth="410" Margin="5,5,5,5" HorizontalAlignment="Left" />
                    </StackPanel>
                    
                    <StackPanel x:Name="pnlTableOverwrite" Height="Auto" Width="Auto" Background="Gold" Visibility="Visible" Margin="0,0,0,2">
                        <StackPanel x:Name="pnlTableOverwriteTop" Height="2" Width="Auto" Background="Goldenrod"/>
                        <TextBlock x:Name="txtTableOverwrite" Text="Warning: The table metaFields will be overwritten if you proceed. This action cannot be undone." TextWrapping="WrapWithOverflow" MaxWidth="410" Margin="5,5,5,5" HorizontalAlignment="Left" />
                    </StackPanel>

                    <StackPanel x:Name="pnlProgress" Height="Auto" Width="Auto" Background="PaleGreen" Visibility="Visible" Margin="0,0,0,2">
                        <StackPanel x:Name="pnlProgressTop" Height="2" Width="Auto" Background="Green"/>                        
                        <TextBlock x:Name="txtProgress" Visibility="Visible" Text="Creating output table..." TextWrapping="WrapWithOverflow" MaxWidth="410" Margin="5,5,5,5" HorizontalAlignment="Left" />                        
                        <ProgressBar x:Name="progressBar" Height="18" Margin="4, 2, 4, 8" Visibility="Collapsed" />
                        
                    </StackPanel>
                </StackPanel>
                    
                        <Grid Grid.ColumnSpan="4" Grid.Column="0" Grid.Row="3">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="115"/>
                                <ColumnDefinition Width="115"/>
                                <ColumnDefinition Width="115"/>
                            </Grid.ColumnDefinitions>
                        
                        <Button x:Name="btnExport" Width="100" Content="Export" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" Click="btnExport_Click" />
                        <Button x:Name="btnCancel" Width="100" Content="Close" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Click="btnCancel_Click" />
                        </Grid>               

                </StackPanel>                    
        </Grid>
        <Image x:Name="imgClose" Source="Images\x.png" HorizontalAlignment="Right" VerticalAlignment="Top"/>
    </Grid>
    
</UserControl>
